package com.xfatm.killer.entity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by wenjie on 2018/3/24.
 */

public class MainPageAdapter extends FragmentStatePagerAdapter{

    private List<TabFragment> fragments;

    public MainPageAdapter(FragmentManager fm,List<TabFragment> fragments) {
        super(fm);
        this.fragments=fragments;
        /*for(MainTabEnum tabEnum:MainTabEnum.values()){
            fragments.add(TabFragment.newInstance(tabEnum.getTitle()));
        }*/
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return fragments.get(position).mainTabEnum.getTitle();
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
